import 'package:flutter/material.dart';
import 'package:module/dingdan_page.dart';
import 'package:module/huodong_page.dart';
import 'package:module/me_page.dart';
import 'package:module/shouye_page.dart';

class IndexPage extends StatefulWidget {
  const IndexPage({super.key});

  @override
  State<IndexPage> createState() => _IndexPageState();
}

class _IndexPageState extends State<IndexPage> {
  int _index = 3;

  List<Widget> _Page = [ShouYePage(), HuoDongPage(), DingDanPage(), MePage()];

  void _onItemTapped(int index) {
    setState(() {
      _index = index;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: _Page[_index],
      bottomNavigationBar: BottomNavigationBar(
        onTap: _onItemTapped,
        currentIndex: _index,
        type: BottomNavigationBarType.fixed,
        fixedColor: Color(0xFFF98B31),
        items: [
          BottomNavigationBarItem(
              icon: Image.asset(
                'assets/icon_home.png',
                width: 24,
              ),
              activeIcon: Image.asset(
                'assets/icon_home_active.png',
                width: 24,
              ),
              label: '首页'),
          BottomNavigationBarItem(
              icon: Image.asset(
                'assets/icon_activity.png',
                width: 24,
              ),
              activeIcon: Image.asset(
                'assets/icon_activity_active.png',
                width: 24,
              ),
              label: '活动'),
          BottomNavigationBarItem(
              icon: Image.asset(
                'assets/icon_order.png',
                width: 24,
              ),
              activeIcon: Image.asset(
                'assets/icon_order_active.png',
                width: 24,
              ),
              label: '订单'),
          BottomNavigationBarItem(
              icon: Image.asset(
                'assets/icon_my.png',
                width: 24,
              ),
              activeIcon: Image.asset(
                'assets/icon_my_active.png',
                width: 24,
              ),
              label: '我的'),
        ],
      ),
    );
  }
}
